Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runtime): use micromamba instead of mamba and fix build issue #4154

Merged
merged 31 commits into from
Oct 2, 2024

Conversation

xingyaoww
Copy link
Collaborator

@xingyaoww xingyaoww commented Oct 1, 2024

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

End-user friendly description of the problem this fixes or functionality that this introduces

Improve the docker runtime build speed & fix bugs in build


Give a summary of what the PR does, explaining any non-trivial design decisions

micromamba is a fully statically-linked, self-contained, executable. This means that the base environment is completely empty. The configuration for micromamba is slightly different, namely all environments and cache will be created by default under the MAMBA_ROOT_PREFIX environment variable. There is also no pre-configured .condarc/.mambarc shipped with micromamba (they are however still read if present).

This means micromamba is faster to install than miniforge/mamba, which will help in evaluation scenario where you may need to build thousands of containers..

This PR:


Link of any specific issues this addresses

May fix #4153

Should also fix #4164

Some explanation of how this can fix #4153 #4164

slack message link

  • You build an image from scratch with mamba x.x.8 -> oh_v0.9.7_XXX
  • You skip init and rebuild a new image using FROM oh_v0.9.7_XXX and you try to install playwright
  • while installing playwright, mamba's dependency resolver decide that you should downgrade mamba x.x.8 to x.x.7 in the base environment
  • bingo -- mamba is now broken in this issue [Bug]: Runtime failed to build due to Mamba Error #4153.

The root issue is that we install useful stuff (playwright) in the base environment (where core mamba/conda reside), which is discouraged: https://mamba.readthedocs.io/en/latest/user_guide/troubleshooting.html#no-other-packages-should-be-installed-to-base

@tobitege
Copy link
Collaborator

tobitege commented Oct 1, 2024

in the docker script:

RUN mkdir -p /openhands/micromamba &&     curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj -C /openhands/micromamba

I think the tar is creating a different folder structure below micromamba?
Maybe this works?

RUN curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj -C /tmp && \
    mv /tmp/micromamba /openhands/

RUN /openhands/micromamba/bin/micromamba create -n openhands python=3.11 -y
RUN /openhands/micromamba/bin/micromamba install -n openhands -c conda-forge poetry -y

@xingyaoww
Copy link
Collaborator Author

You are probably right! Though the weird thing is i can build the exact dockerfile locally, as well as on the remote runtime 😓. I confirmed that this PR allow the previously fail image to successfully build and run

@enyst
Copy link
Collaborator

enyst commented Oct 1, 2024

Just to note for the record: when we have switched from miniconda to miniforge3, part of the discussion there had a licensing reason, because anaconda's own licensing is messy. I made a quick check around micromamba from the licensing point of view and it looks good to me. 👍

(it's similar to miniforge3, BSD 3-clause licensed software, scripts, default conda-forge channel.)

@xingyaoww
Copy link
Collaborator Author

Set CONDA_FORGE_YES to yes seems to also include Anaconda's commercial source when I'm testing the RemoteRuntime:

 ---> be5325871eaf
Step 8/12 : RUN /openhands/micromamba/bin/micromamba create -n openhands python=3.11 -y &&     /openhands/micromamba/bin/micromamba install -n openhands conda-forge::poetry -y
 ---> Running in ee1c0d20abcf
warning  libmamba 'repo.anaconda.com', a commercial channel hosted by Anaconda.com, is used.
    
warning  libmamba Please make sure you understand Anaconda Terms of Services.
    
warning  libmamba See: https://legal.anaconda.com/policies/en/
warning  libmamba 'repo.anaconda.com', a commercial channel hosted by Anaconda.com, is used.
    
warning  libmamba Please make sure you understand Anaconda Terms of Services.
    
warning  libmamba See: https://legal.anaconda.com/policies/en/
warning  libmamba 'repo.anaconda.com', a commercial channel hosted by Anaconda.com, is used.
    
warning  libmamba Please make sure you understand Anaconda Terms of Services.
    
warning  libmamba See: https://legal.anaconda.com/policies/en/
warning  libmamba 'repo.anaconda.com', a commercial channel hosted by Anaconda.com, is used.
    
warning  libmamba Please make sure you understand Anaconda Terms of Services.
    
warning  libmamba See: https://legal.anaconda.com/policies/en/

error    libmamba Could not lock non-existing path '/root/.mamba/pkgs'

Try set it back to no to see if it work (i think conda-forge::poetry which be equivalent to -c conda-forge which might work?)

@enyst
Copy link
Collaborator

enyst commented Oct 1, 2024

Set CONDA_FORGE_YES to yes seems to also include Anaconda's commercial source when I'm testing the RemoteRuntime:

That's strange! I think the install script does this?

# Initializing conda-forge
case "$CONDA_FORGE_YES" in
  y|Y|yes)
    "${BIN_FOLDER}/micromamba" config append channels conda-forge
    "${BIN_FOLDER}/micromamba" config append channels nodefaults
    "${BIN_FOLDER}/micromamba" config set channel_priority strict
    ;;
esac

@xingyaoww xingyaoww changed the title feat(runtime): use micromamba instead of mamba for effeciency feat(runtime): use micromamba instead of mamba and fix build issue Oct 2, 2024
@xingyaoww xingyaoww marked this pull request as ready for review October 2, 2024 20:56
Copy link
Collaborator

@tobitege tobitege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, awaiting the tests go through.
Thanks for the hard work! 🙏

@xingyaoww xingyaoww enabled auto-merge (squash) October 2, 2024 21:13
@xingyaoww xingyaoww merged commit e81c559 into main Oct 2, 2024
@xingyaoww xingyaoww deleted the xw/micromamba branch October 2, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Docker image build failing for SWE-Bench evaluation [Bug]: Runtime failed to build due to Mamba Error
3 participants